#include <iostream>
#include <functional>
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>

using namespace std;

void *func(void *)
{

    for (int i = 0; i < 30; i++)
    {
        std::cout << "id" << pthread_self() << " num:" << i << std::endl;
    }
    return;
}

void signal_handler(int signo)
{
    if (signo == SIGINT)
    {
        std::cout << "sigINt is interrupt" << std::endl;
    }
}

int main()
{
    if (signal(SIGINT, signal_handler) == SIG_ERR)
    {
        perror("signal");
        exit(1);
    }

    pthread_t rabbit;
    if (pthread_create(&rabbit, NULL, func, NULL) < 0)
    {

        perror("pthread_create");
        exit(1);
    }  

    pthread_join(rabbit, NULL);

    return 0;
}